from django.template import Library
from operate.models import Collect
register = Library()


@register.filter
def my_length(value, n):
    return len(value) + n


@register.filter
def has_collected(book, user):
    c = Collect.objects.filter(book=book, user=user).first()
    return True if c else False
